home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / Multimedia / MPC-HC / MPC-HC-x64-Portable.exe / MPC-HC-x64-Portable / Shaders / BT.601 to BT.709.hlsl < prev    next >
Text File  |  2014-10-05  |  2KB  |  38 lines

  1. /*
  2.  * (C) 2011 Jan-Willem Krans (janwillem32 <at> hotmail.com)
  3.  * (C) 2011-2013 see Authors.txt
  4.  *
  5.  * This file is part of MPC-HC.
  6.  *
  7.  * MPC-HC is free software; you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License as published by
  9.  * the Free Software Foundation; either version 3 of the License, or
  10.  * (at your option) any later version.
  11.  *
  12.  * MPC-HC is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.  * GNU General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU General Public License
  18.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  19.  *
  20.  */
  21.  
  22. // Correct video colorspace BT.601 [SD] to BT.709 [HD] for HD video input
  23. // Use this shader only if BT.709 [HD] encoded video is incorrectly matrixed to full range RGB with the BT.601 [SD] colorspace.
  24.  
  25. sampler s0;
  26. float2  c0;
  27.  
  28. float4 main(float2 tex : TEXCOORD0) : COLOR
  29. {
  30.     float4 si = tex2D(s0, tex); // original pixel
  31.     if (c0.x < 1120 && c0.y < 630) {
  32.         return si; // this shader does not alter SD video
  33.     }
  34.     float3 s1 = si.rgb;
  35.     s1 = s1.rrr * float3(0.299, -0.1495 / 0.886, 0.5) + s1.ggg * float3(0.587, -0.2935 / 0.886, -0.2935 / 0.701) + s1.bbb * float3(0.114, 0.5, -0.057 / 0.701); // RGB to Y'CbCr, BT.601 [SD] colorspace
  36.     return (s1.rrr + float3(0, -0.1674679 / 0.894, 1.8556) * s1.ggg + float3(1.5748, -0.4185031 / 0.894, 0) * s1.bbb).rgbb; // Y'CbCr to RGB output, BT.709 [HD] colorspace
  37. }
  38.